<h2><img src="./components/com_install/icon.png" alt="Install" width="80" height="80" /> Instalátor komponent</h2>
<form action="" method="post" enctype="multipart/form-data">
<table>
<tr>
<td><input type="file" name="new_com" size="50" /></td>
<td><?php echo Lang::getBackGlobal('install_zip'); ?></td>
</tr>

<tr><td><input type="submit" value="<?php echo Lang::getBackGlobal('submit'); ?>" /></td></tr>
</table>
</form>
<?php

/**
 * @author 
 * @copyright 2009
 */
echo '<span style="background:#f7f6f0; padding-left: 8px;">';
if(!empty($_FILES['new_com']['name'])){
	$out = "";
	$folder = '../temp';
    $result = $folder . "/".$_FILES['new_com']['name'];
    $file = $_FILES['new_com']['tmp_name'];
    $copy = @move_uploaded_file($file, $result);
    @chmod ($result, 0777);
    if($copy === false){
    	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_temp')."</p>\n";
    	$unzip = false;
    }else{
    	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_temp2')."</p>\n";
    	$unzip = true;
    }
    $name = basename($result, '.zip');
    if(!is_dir('../components/'.$name.'/')){
    
    if($unzip and in_array(strtolower(pathinfo($_FILES["new_com"]["name"], PATHINFO_EXTENSION)), $ext)){
    	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_extension')."</p>";
    	$zip = new ZipArchive;
    	$res = $zip->open($result);
		if ($res === TRUE) {
    		$zip->extractTo('../components/');
         	$zip->close();
         	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_done')."</p>";
         	unlink($result);
         	$name = basename($result, '.zip');
         	
         	$log->write(8, 'com_install', 'NOW()', 'User installed a new component '.$_FILES['new_com']['name'], $_SESSION['id']);
         	
         	if(is_file('../components/'.$name.'/install.php')){
         		define('COM_INSTALL', true);
         		require_once '../components/'.$name.'/install.php';
         	}
         	
    	}else{
    		$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_open')."</p>";
    		unlink($result);
    	}
    }else{
    	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_extension2')."</p>";
    	unlink($result);
    }
	}else{
    	$out .= "<p class=\"msg done\">".Lang::getBackGlobal('install_exist')."</p>";
    }
    echo $out . "\n</span>";
}

?>